#!/bin/sh
################################################################
#将本地mysql 开发库同步至远程服务器开发库
################################################################

/usr/local/mysql/bin/mysqldump -uroot -pP@ssw0rd123456 foxnic >/tmp/db.sql
cd /tmp
rm -rf db.tar.gz
tar -zcvf db.tar.gz db.sql

xi me /tmp/db.tar.gz

cur_dir=$(cd `dirname $0`; pwd)
conf_file=$cur_dir/app.conf
hostname=`hostname`
tmp_dir=`cat $conf_file|grep ${hostname}.ops_dir|awk -F "=" '{print $2}'`
jar_dir=`cat $conf_file|grep ${hostname}.jar_dir|awk -F "=" '{print $2}'`
ops_jar_dir=`cat $conf_file|grep ${hostname}.ops_jar_dir|awk -F "=" '{print $2}'`
ops=$ops_jar_dir/ops.jar.1
ops_node_file="$tmp_dir/ops.node"
JAVA=java
ops_conf="/tmp/ops.conf"


echo "">$ops_conf
echo "if [[ ! -f \"/tmp/db.tar.gz\" ]];then                                          ">>$ops_conf
echo "  echo \"file not found,failed\"                                                           ">>$ops_conf
echo "  exit 1                                                                                  ">>$ops_conf
echo "fi                                                                                           ">>$ops_conf
echo "cd /tmp                 ">>$ops_conf
echo "rm -rf db.sql            ">>$ops_conf
echo "tar xvf db.tar.gz        ">>$ops_conf
echo " sh /app/app/bin/runSql.sh /tmp/db.sql foxnic ">>$ops_conf
$JAVA  -jar $ops -e action -n $ops_node_file -c $ops_conf




exit 0





/usr/local/mysql/bin/mysql -uroot -pP@ssw0rd123456 -hlocalhost
/usr/local/mysql/bin/mysql -uroot -pP@ssw0rd123456  -hlocalhost
/usr/local/mysql/bin/mysql -root -pP@ssw0rd123456 -hlocalhost
alter user 'root'@'localhost' identified with mysql_native_password by 'P@ssw0rd123456'
update mysql.user set host='%' where user='root';








